import Taro from '@tarojs/taro';
import api from '../constants/api';
import {getJSON, postJSON} from '../utils/request';

// 验证 accesstoken
export function userAccessToken(params) {
    return async dispatch => {
        let result = await postJSON(api.checkusertoken, params);
        if (result && result.data && result.data.success) {
            dispatch({type: "loginSuccess", accesstoken: params.accesstoken, loginname: result.data})
            return result.data
        } else {
            dispatch({type: "loginFail", accesstoken: null, loginname: null})
        }
        return false;
    }
}
